<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=0.5,minimum-scale=0.5,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>购物车</title>
    <link rel="stylesheet" type="text/css" href="__CSS__/api.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/aui.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/dropload.css" />
    <style>
        body {
            background-color: #F4F4F4;
        }
        .outer{
            background-color: #fff;
            padding-left: 20px;
            padding-right: 20px;
        }
        .inner{
            border-bottom: 1px solid #D8D8D8;
        }
        .shoppic {
            width: 28px;
            height: 27px;
            margin-top: 34px;
        }

        .tit {
            font-size: 28px;
            color: #555555;
            padding-top: 30px;
            padding-left: 18px;
            padding-right: 20px;
        }

        .arrow {
            width: 20px;
            height: 22px;
            background: url(__IMG__/right_arrow.png) no-repeat center center;
            background-size: 12px 22px;
            margin-top: 36px;
        }

        .label {
            display: inline-block;
            height: 32px;
            padding-left: 6px;
            padding-right: 6px;
            color: #F04040;
            font-size: 20px;
            text-align: center;
            border-radius: 6px;
            position: relative;
            line-height: 32px;
            text-align: center;
            margin-top: 8px;
            border: 1px solid #F04040;
            margin-right: 22px;
        }

        .right {
            padding-bottom: 18px;
        }

        .advice {
            font-size: 26px;
            color: #404040;
            padding-left: 4px;
            display: inline-block;
            padding-top: 4px;
        }
        .delete{
            width: 32px;
            height: 32px;
            margin-top: 55px;
        }
        .delete img{
            width: 32px;
            height: 32px;
        }
        .title{
            font-size: 28px;
            color:#404040;
            padding-right: 9px;
            width:220px;
            height:36px;
        }
        .label1 {
            display: inline-block;
            height: 36px;
            padding-left: 6px;
            padding-right: 6px;
            color: #F04040;
            font-size: 28px;
            text-align: center;
            border-radius: 4px;
            position: relative;
            line-height: 36px;
            text-align: center;
            margin-top: 3px;
            border: 1px solid #F04040;
        }

        .price{
            font-size: 28px;
            color: #F04040;
            padding-right:64px;
        }
        .price1{
            font-size: 20px;
            color: #F04040;
        }
        .jian,
        .jia {
            width: 40px;
            height: 40px;
        }
        .number {
            padding-left:45px;
            padding-right:45px;
            font-size: 28px;
            color: #666;
        }
        .one{
            padding-bottom: 33px;
        }
        .goods{
            background-color: #fff;
            padding-left: 20px;
            padding-right: 20px;
            padding-top:30px;
        }
        .total_price{
            border-bottom: 1px solid #D8D8D8;
            padding-top:10px;
            padding-bottom: 30px;
        }
        .total{
            font-size: 42px;
            color:#404040;
            font-weight:bold;
        }
        .all{
            font-size: 28px;
            color:#404040;
        }
        .btn{
            background-color: #fff;
            padding-left: 20px;
            padding-right: 20px;
            padding-top:30px;
            padding-bottom:30px;
        }
        .button{
            height:88px;
            line-height:88px;
            text-align: center;
            font-size: 32px;
            color:#FFFFFF;
            font-weight: bold;
            background-color: #FF5757;
            border-radius:1px;
        }
        .single{
            margin-top:12px;
        }

        .imggggggg{
            width: 50px;
            height: 50px;
            margin-right:10px;
        }

    </style>
</head>

<body>
<div class="seat1 {if $data}hidden{/if}" id="seatAll">
    <img src="__IMG__/quexing/no_content.png" class="seatImg1"/>
    <div class="seatName1">没有符合条件的内容</div>
</div>

<div id="list"></div>
   {volist name='data' id='d'}
    <div class="single" id="all_{$d.car_id}">
        <div class="outer">
            <div class="flex-wrap inner">
                <div class="flex-con  right">
                    <div class="flex-wrap" onclick="homepage({$d.car_shopid})">
                        <img src="__IMG__/shop.png" class="shoppic">
                        <div class="tit">{$d.s_name}</div>
                        <div class="arrow"></div>
                    </div>
                    <div class="flex-wrap">
                        <div class="label">本店活动</div>
                        <div class="advice">{$d.manjian_rule_str ?? ''}</div>
                    </div>
                </div>
                <div class="delete" car_id="{$d.car_id}" onclick="delectAllOne(this)"><img src="__IMG__/del1.png"></div>
            </div>
        </div>
        <div class="goods">
            <?php $a = 0; ?>
            {volist name="d['goods']" id='g'}
            <div class="one flex-wrap" id="allOne_{$g.g_id}">
                <img src="{$g.g_thumb ?? '__IMG__/zhanweitu/a3.png'}" class="imggggggg">
                <div class="title">{$g.g_name}</div>
                {if $g.g_prcie_kill > 0}
                <div class="label1">秒杀</div>
                {/if}
                <div class="flex-con"></div>
                <div class="price">
                    {if $g.g_prcie_kill > 0 }
                    <?php $a += $g['g_prcie_kill']*$g['car_number']; ?>
                    <span class="price1">￥</span>{$g.g_prcie_kill}
                    {else /}
                    <?php $a += $g['g_price_now']*$g['car_number']; ?>
                    <span class="price1">￥</span>{$g.g_price_now}
                    {/if}

                </div>
                <div class="jian" car_id="{$d.car_id}" g_price_now="{$g.g_price_now}" g_prcie_kill="{$g.g_prcie_kill}" tapmode onclick="delectOneProduct(this)" g_id="{$g.g_id}"><img src="__IMG__/jian.png"></div>
                <div class="number" id="numberrr_{$g.g_id}">{$g.car_number}</div>
                <div class="jia" car_id="{$d.car_id}" g_price_now="{$g.g_price_now}" g_prcie_kill="{$g.g_prcie_kill}" tapmode onclick="addOneProduct(this)" g_id="{$g.g_id}"><img src="__IMG__/add.png"></div>
            </div>
            {/volist}
            <div class="flex-wrap total_price">
                <div class="flex-con"></div>
                <div class="total"><span class="all">总计￥ </span><span id="allMoney_{$d.car_id}">{$a}</span></div>
            </div>
        </div>
        <div class="btn">
            <div class="button" car_shopid="{$d.car_shopid}" onclick="toPayyy(this)">去结算</div>
        </div>
    </div>
    {/volist}
</body>
{include file="public/footer2" /}
<script type="text/javascript" src="__JS__/dropload.min.js"></script>
<script type="text/javascript" src="__JS__/tt.js"></script>
<script type="text/javascript" src="__JS__/layer_mobile/layer.js"></script>
<script type="text/javascript">
    function homepage(s_id) {
        location.href = '{:url("Index/shopInfo")}?s_id='+s_id;
    }
    //删除一个全部
    function delectAllOne(el){
        var car_id= $(el).attr('car_id');
        if(confirm('确定要删除吗？')){
            $.ajax({
                url:'{:url("Car/deleteMyCar")}',
                data: 'car_id='+car_id,//
                type:'POST',
                dataType:'JSON',
                success: function(returndata){
                    if(returndata.status == 200){
                        $('#all_'+car_id).remove();
                        return;
                    }else{
                        alert(returndata.msg);
                        return;
                    }
                },
                error:function () {
                    alert('Ajax error!');
                }
            })
        }
    }
    /**
     * 减一个
     */
    function delectOneProduct(el) {
        var gid = $(el).attr('g_id');
        var now = $(el).attr('g_price_now');
        var kill = $(el).attr('g_prcie_kill');
        var carid = $(el).attr('car_id');
        $.ajax({
            url: '{:url("home/Index/putGoodInCar")}',
            data: 'g_id=' + gid + '&type=2',//
            type: 'POST',
            dataType: 'JSON',
            success: function (data) {
                if (data.status == 200) {
                    allmoney(2,now,kill,carid);
                    var num = $('#numberrr_'+gid).text();
                    $('#numberrr_'+gid).text(num-1);
                    if(num <= 1){
                        $('#allOne_'+gid).remove();
                    }
                    return;
                } else if(data.status == 4){
                    location.href = '{:url("home/Login/gologin")}';
                }else{
                    alert(data.msg);
                    return;
                }
            },
            error: function () {
                alert('Ajax error!');
            }
        })
    }
    /**
     * 加一个
     */
    function addOneProduct(el) {
        var gid = $(el).attr('g_id');
        var now = $(el).attr('g_price_now');
        var kill = $(el).attr('g_prcie_kill');
        var carid = $(el).attr('car_id');
        $.ajax({
            url: '{:url("home/Index/putGoodInCar")}',
            data: 'g_id=' + gid + '&type=1',//
            type: 'POST',
            dataType: 'JSON',
            success: function (data) {
                if (data.status == 200) {
                    allmoney(1,now,kill,carid);
                    var num = $('#numberrr_'+gid).text();
                    $('#numberrr_'+gid).text(num-0+1);
                    return;
                } else if(data.status == 4){
                    location.href = '{:url("home/Login/gologin")}';
                }else{
                    alert(data.msg);
                    return;
                }
            },
            error: function () {
                alert('Ajax error!');
            }
        })
    }
    //加减的计算
    function allmoney(type,now,kill,carid) {
        now = parseFloat(now);
        kill = parseFloat(kill);
        if(kill > 0){
            now = kill;
        }
        var money = parseFloat($('#allMoney_'+carid).text());
        if(type == 2){
            $('#allMoney_'+carid).text(money-now);
            if(money-now <= 0){
                $('#all_'+carid).remove();
            }
        }else{
            $('#allMoney_'+carid).text(money-0+now);
        }
        return true;
    }
    /**
     * 去结算
     */
    function toPayyy(el) {
        var sid = $(el).attr('car_shopid');
        location.href = '{:url("Car/sureOrder")}?shopid='+sid;
    }
    pushHistory();
    window.addEventListener("popstate", function(e) {
        window.close();
        WeixinJSBridge.call('closeWindow');
    }, false);
    function pushHistory() {
        var state = {
            title: "title",
            url: "#"
        };
        window.history.pushState(state, "title", "#");
    }
    XBack.listen(function(){
        alert('back');
    });
</script>

</html>
